from django.http import HttpResponse
from django.shortcuts import render
from django.utils.decorators import method_decorator
from django.views import View

def my_decorator(func):
    def wrapper(request, *args, **kwargs):
        print('自定义的装饰器被调用了')
        print('请求路径%s'%request.path)
        return func(request, *args, **kwargs)
    return wrapper


# @method_decorator(my_decorator, name='get')
# @method_decorator(my_decorator, name='dispatch')
class IndexView(View):
    def get(self,request):
        # 处理get请求
        return HttpResponse('类视图处理get请求')

    def post(self,request):
        return HttpResponse('类视图，处理post请求')

    def put(self,request):
        return HttpResponse('类视图，处理post请求')